package se.webbzon.boltzmann.menu;

import java.awt.Color;
import java.awt.Dimension;

import se.webbzon.oschi01.font.HorizontalAlignment;
import se.webbzon.oschi01.worldcamera.WorldCameraPane;

public class MOverlay extends MItem {
	
	// The text of this menu overlay
	private final MText text;
	
	/*============================================================
	Constructors
	============================================================*/
	
	public MOverlay(TextLayout layout, String text) {
		super(-1);
		this.text = new MText(layout,text);
		this.text.setHAlignment(HorizontalAlignment.CENTER);
		this.text.setShadow(true);
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	/** Returns the text of this game menu overlay. **/
	public String getText() {
		return text.getText();
	}

	/** Sets the text of this game menu overlay. **/
	public void setText(String text) {
		this.text.setText(text);
	}

	/** Returns the color of this game menu overlay. **/
	public Color getColor() {
		return text.getColor();
	}
	
	/** Sets the color of this game menu overlay. **/
	public void setColor(Color color) {
		this.text.setColor(color);
	}

	@Override public void onDraw(GameMenu menu, WorldCameraPane hud) {
		hud.setTransparency(0.8f);
		hud.setColor(Color.gray);
		Dimension d = new Dimension();
		hud.getLayer().getDimension(d);
		hud.fillRect(0, 0, d.width, d.height);
		hud.setTransparency(1);
		text.draw(hud, d.width/2, d.height/2);
	}

	@Override public void onPress(GameMenu menu, int x, int y) {}

	@Override public void onRelease(GameMenu menu, int x, int y) {}

	@Override public boolean isDraggable() {
		return false;
	}

	@Override public boolean isFocusable() {
		return false;
	}

}
